/**
 */
package org.cmoine.perspectiveshare.model.impl;

import org.cmoine.perspectiveshare.model.LayoutType;
import org.cmoine.perspectiveshare.model.MainWindowType;
import org.cmoine.perspectiveshare.model.PerspectivesPackage;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Layout Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.cmoine.perspectiveshare.model.impl.LayoutTypeImpl#getMainWindow <em>Main Window</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class LayoutTypeImpl extends EObjectImpl implements LayoutType {
    /**
     * The cached value of the '{@link #getMainWindow() <em>Main Window</em>}' containment reference.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getMainWindow()
     * @generated
     * @ordered
     */
    protected MainWindowType mainWindow;

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    protected LayoutTypeImpl() {
        super();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    protected EClass eStaticClass() {
        return PerspectivesPackage.Literals.LAYOUT_TYPE;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public MainWindowType getMainWindow() {
        return mainWindow;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public NotificationChain basicSetMainWindow(MainWindowType newMainWindow, NotificationChain msgs) {
        MainWindowType oldMainWindow = mainWindow;
        mainWindow = newMainWindow;
        if (eNotificationRequired()) {
            ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PerspectivesPackage.LAYOUT_TYPE__MAIN_WINDOW, oldMainWindow, newMainWindow);
            if (msgs == null) msgs = notification; else msgs.add(notification);
        }
        return msgs;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setMainWindow(MainWindowType newMainWindow) {
        if (newMainWindow != mainWindow) {
            NotificationChain msgs = null;
            if (mainWindow != null)
                msgs = ((InternalEObject)mainWindow).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PerspectivesPackage.LAYOUT_TYPE__MAIN_WINDOW, null, msgs);
            if (newMainWindow != null)
                msgs = ((InternalEObject)newMainWindow).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PerspectivesPackage.LAYOUT_TYPE__MAIN_WINDOW, null, msgs);
            msgs = basicSetMainWindow(newMainWindow, msgs);
            if (msgs != null) msgs.dispatch();
        }
        else if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, PerspectivesPackage.LAYOUT_TYPE__MAIN_WINDOW, newMainWindow, newMainWindow));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
        switch (featureID) {
            case PerspectivesPackage.LAYOUT_TYPE__MAIN_WINDOW:
                return basicSetMainWindow(null, msgs);
        }
        return super.eInverseRemove(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public Object eGet(int featureID, boolean resolve, boolean coreType) {
        switch (featureID) {
            case PerspectivesPackage.LAYOUT_TYPE__MAIN_WINDOW:
                return getMainWindow();
        }
        return super.eGet(featureID, resolve, coreType);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eSet(int featureID, Object newValue) {
        switch (featureID) {
            case PerspectivesPackage.LAYOUT_TYPE__MAIN_WINDOW:
                setMainWindow((MainWindowType)newValue);
                return;
        }
        super.eSet(featureID, newValue);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eUnset(int featureID) {
        switch (featureID) {
            case PerspectivesPackage.LAYOUT_TYPE__MAIN_WINDOW:
                setMainWindow((MainWindowType)null);
                return;
        }
        super.eUnset(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public boolean eIsSet(int featureID) {
        switch (featureID) {
            case PerspectivesPackage.LAYOUT_TYPE__MAIN_WINDOW:
                return mainWindow != null;
        }
        return super.eIsSet(featureID);
    }

} //LayoutTypeImpl
